package com.mhl.entity;

import java.util.ArrayList;


//singleton mode
public class User {


    private static User instance;
    private ArrayList<Product> userProvideList;
    private ArrayList<Product> userStarList;
    private ArrayList<Product> userOrderList;
    private String username;
    //private String nickname;
    private String userPassword;
    private int userId;
    private int userGender;
    private String userDescription;
    private ArrayList<Integer> userLike = new ArrayList<>();


    private User (){}

    public static User getInstance() {
        if (instance == null) {
            instance = new User();
        }
        return instance;
    }

    public static ArrayList<Product> getUserOrderList() {
        if (instance == null) {
            instance = new User();
        }
        return instance.userOrderList;
    }

    public static ArrayList<Product> getUserProvideList() {
        if (instance == null) {
            instance = new User();
        }
        return instance.userProvideList;
    }

    public static ArrayList<Product> getUserStarList() {
        if (instance == null) {
            instance = new User();
        }
        return instance.userStarList;
    }

    public static ArrayList<Integer> getUserLike() {
        if (instance == null) {
            instance = new User();
        }
        return instance.userLike;
    }

    public static String getUsername() {
        if (instance == null) {
            instance = new User();
        }
        return instance.username;
    }

//    public static String getUserNickname() {
//        if (instance == null) {
//            instance = new User();
//        }
//        return instance.nickname;
//    }

    public static int getUserId() {
        if (instance == null) {
            instance = new User();
        }
        return instance.userId;
    }

    public static int getUserGender() {
        if (instance == null) {
            instance = new User();
        }
        return instance.userGender;
    }

    public static String getUserDescription() {
        if (instance == null) {
            instance = new User();
        }
        return instance.userDescription;
    }

    public static String getUserPassword() {
        if (instance == null) {
            instance = new User();
        }
        return instance.userPassword;
    }

    public static void setUserProvideList(ArrayList<Product> userProvideList){
        if (instance == null) {
            instance = new User();
        }
        instance.userProvideList = userProvideList;;
    }

    public static void setUserStarList(ArrayList<Product> userStarList){
        if (instance == null) {
            instance = new User();
        }
        instance.userStarList = userStarList;
    }

    public static void setUserOrderList(ArrayList<Product> userOrderList){
        if (instance == null) {
            instance = new User();
        }
        instance.userOrderList = userOrderList;
    }

    public static void setUserLike(ArrayList<Integer> userLike){
        if (instance == null) {
            instance = new User();
        }
        instance.userLike = userLike;
    }

    public static void setUsername(String username) {
        if (instance == null) {
            instance = new User();
        }
        instance.username = username;
    }

//    public static void setUserNickname(String nickname) {
//        if (instance == null) {
//            instance = new User();
//        }
//        instance.nickname = nickname;
//    }

    public static void setUserId(int userId) {
        if (instance == null) {
            instance = new User();
        }
        instance.userId = userId;
    }

    public static void setUserGender(int userGender) {
        if (instance == null) {
            instance = new User();
        }
        instance.userGender = userGender;
    }

    public static void setUserDescription(String userDescription) {
        if (instance == null) {
            instance = new User();
        }
        instance.userDescription = userDescription;
    }

    public static void setUserPassword(String userPassword) {
        if (instance == null) {
            instance = new User();
        }
        instance.userPassword = userPassword;
    }

    public static void resetUser(){
        //instance.userStarList.clear();
        instance.username = "";
        instance.userId = 0;
        instance.userDescription = "";
        instance.userLike.clear();
        instance.userPassword = "";
        instance.userGender = 0;

    }
}
